package com.zrulin.findcomrade.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zrulin.findcomrade.mapper.UserMapper;
import com.zrulin.findcomrade.pojo.User;
import com.zrulin.findcomrade.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author zrulin
 * @create 2021-04-21 21:17
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;

    @Override
    public User queryByUsernameAndPassword(String username, String password) {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("username",username);
        wrapper.eq("password",password);
        return userMapper.selectOne(wrapper);
    }

    @Override
    public User queryByUsername(String username) {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("username",username);
        return userMapper.selectOne(wrapper);

    }

    @Override
    public void save(User user) {
       userMapper.insert(user);
    }
}
